package com.lg.cms.controller.news1;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.lg.cms.entity.Template1;
import com.lg.cms.entity.TemplateTypePath1;
import com.lg.cms.mapper.Template1Mapper;
import com.lg.cms.mapper.TemplateTypePath1Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * 前端页面映射
 * 2020—11—20 10:15
 */
@Controller
@RequestMapping("/cms")
public class Uews1Controller {
    @Autowired
    TemplateTypePath1Mapper typePathMapper1;
    @Autowired
    Template1Mapper template1Mapper;

    /**
     * 首页
     */
    @GetMapping("/index")
//    @ResponseBody
    public String index() {
        Template1 template1 = template1Mapper.selectOne(Wrappers.<Template1>lambdaQuery().eq(Template1::getUse, 1));
        TemplateTypePath1 typePath1 = typePathMapper1.selectOne(Wrappers.<TemplateTypePath1>lambdaQuery().eq(TemplateTypePath1::getEnable, 1)
                .eq(TemplateTypePath1::getTemplateTypeId, 1));
        if (typePath1 == null) {
            typePath1 = typePathMapper1.selectOne(Wrappers.<TemplateTypePath1>lambdaQuery().eq(TemplateTypePath1::getIsDefault, 1)
                    .eq(TemplateTypePath1::getTemplateTypeId, 1).eq(TemplateTypePath1::getTemplateId, template1.getId()));
        }
        return typePath1.getPath();
    }
}
